<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">


    <ui:define name="title">
        <h:outputText value="#{bundle.ViewUserTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body" >
        <h:form  id="form" styleClass="form">
            <p:fieldset legend="User Information "  >
                <div class="icon_left">
                    <h:commandLink  action="/user/List" styleClass="menu_item" >
                            <h:graphicImage  value="../resources/images/syscon/user_one.png"   />
                            <br/>
                            <h:outputText  value="User Control"/>
                    </h:commandLink>
                </div>
                <h:outputText value="#{userController.current.userLogin}" styleClass="engraved"/>
                <br/>
                <h:outputText value="#{bundle.ViewUserLabel_userId}" styleClass="label"/>
                <h:outputText value="#{userController.current.userId}" title="#{bundle.ViewUserTitle_userId}"/>
                <p:spacer width="10"/>
                <h:outputText value="#{bundle.ViewUserLabel_userLogin}" styleClass="label"/>
                <h:outputText value="#{userController.current.userLogin}" title="#{bundle.ViewUserTitle_userLogin}"/>
                <p:spacer width="10"/>
                <h:outputText value="#{bundle.ViewUserLabel_userEmail}" styleClass="label"/>
                <h:outputText value="#{userController.current.userEmail}" title="#{bundle.ViewUserTitle_userEmail}"/>
                <p:spacer width="10"/>
                <h:outputText value="#{bundle.ViewUserLabel_userCreation}" styleClass="label"/>
                <h:outputText value="#{userController.current.userCreation}" title="#{bundle.ViewUserTitle_userCreation}">
                    <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                </h:outputText>
                <p:spacer width="10"/>
                <h:outputText value="#{bundle.ViewUserLabel_userLive}" styleClass="label"/>
                <p:selectBooleanCheckbox value="#{userController.current.userLive}" disabled="true"/>
                <p:spacer width="10"/>
                <p:separator/>
                <c:if test="#{userController.allowedGroups('1,2')}">
                    <p:commandButton icon="ui-icon-pencil" ajax="false" action="#{userController.prepareEdit}" value="Edit"/>
                    <p:spacer width="10"/>
                    <p:commandButton icon="ui-icon-plus" ajax="false" action="#{userController.prepareCreate}" value="New" />
                    <p:spacer width="10"/>
                </c:if>
                <c:if test="#{userController.allowedGroups('1')}">
                    <p:commandButton icon="ui-icon-close" action="#{userController.destroyAndView}" value="Delete" />
                    <p:spacer width="10"/>

                </c:if>
                <br/>
                <br/>
                <p:panel id="groups" styleClass="sub" header="User Groups"  >
                    <c:if test="#{userController.allowedGroups('2')}">
                        <p:fieldset  legend="Groups"  rendered="#{not empty userController.candidateGroups}">
                            <p:panelGrid columns="3" styleClass="remove_border"  >
                                <p:selectOneMenu  id="can_groups" value="#{userController.selectedUserGroup}" style="width:120px;"  requiredMessage="#{bundle.CreateUserHasGroupRequiredMessage_userGroup}">
                                    <f:selectItems value="#{userController.candidateGroups}" var="userGroup" itemLabel="#{userGroup.grDesc}" itemValue="#{userGroup}" />
                                </p:selectOneMenu>
                                <p:commandButton id="include" value="Include" actionListener="#{userController.addMeToGroup}"   update=":form:" />
                                <p:blockUI block=":form:groups" trigger="include">
                                    <h:outputText value="Please wait, data is being processed..." />  <br/>
                                    <p:graphicImage value="/resources/ajaxloader.gif"/>
                                </p:blockUI>
                            </p:panelGrid>
                        </p:fieldset>
                    </c:if>
                    <br/>
                    <p:dataTable id="userGroup"
                                 value="#{userController.groups}"
                                 rowKey="userGroup"
                                 selection="#{userGroup}"
                                 var="userGroup" >

                        <p:column headerText="Group" style="width: 50px">
                            <center>
                                <p:commandLink value="#{userGroup.grDesc}" action="/userGroup/View?faces-redirect=true" styleClass="button-light">
                                    <f:setPropertyActionListener target="#{userGroupController.current}" value="#{userGroup}"/>
                                </p:commandLink>
                            </center>
                        </p:column>
                        <p:column headerText="Remove" style="width: 50px">
                            <center>
                                <p:commandButton id="remove" icon="ui-icon ui-icon-minusthick" title="Remove #{userGroup.grDesc}" immediate="false" actionListener="#{userController.remMeFromGroup(userGroup)}" update=":form:groups"/>
                                <p:blockUI block=":form:groups" trigger="remove">
                                    <h:outputText value="Please wait, data is being processed..." />  <br/>
                                    <p:graphicImage value="/resources/ajaxloader.gif"/>
                                </p:blockUI>
                            </center>
                        </p:column>
                    </p:dataTable>
                    <br/>

                </p:panel>
                <br/>
                <br/>
            </p:fieldset>
            <br />
        </h:form>
    </ui:define>
</ui:composition>


